import { TIME_PER_FPS } from './config';

export function getData(init, count) {
    const arr = [];
    for (let i = init; i <= count; i++) {
        arr.push(i);
    }
    return arr;
}

//优化-设置上滑、下拉时，加载列表数据的频率
export function setAnimationFrame(callback) {
    let beginTime = Date.now();
    requestAnimationFrame(function cb() {
        const endTime = Date.now();
        callback();
        //上滑、下拉时，每隔TIME_PER_FPS秒加载一次列表数据
        if (endTime - beginTime >= TIME_PER_FPS) {
            beginTime = endTime;
            requestAnimationFrame(cb);
        }
    })
}